import React from 'react';
import { Form, Select } from 'antd';

const UserFilter = ({ departments, onFilterChange }) => {
  const [form] = Form.useForm();

  const handleFilterChange = () => {
    const values = form.getFieldsValue();
    onFilterChange(values);
  };

  return (
    <Form
      form={form}
      layout="inline"
      style={{ marginBottom: '16px' }}
    >
      <Form.Item name="depId" label="所属部门">
        <Select
          style={{ width: 200 }}
          allowClear
          placeholder="选择部门"
          onChange={handleFilterChange}
        >
          {departments.map(dept => (
            <Select.Option key={dept.depId} value={dept.depId}>
              {dept.depName}
            </Select.Option>
          ))}
        </Select>
      </Form.Item>

      <Form.Item name="admin" label="管理员">
        <Select
          style={{ width: 200 }}
          allowClear
          placeholder="选择权限"
          onChange={handleFilterChange}
        >
          <Select.Option value="yes">是</Select.Option>
          <Select.Option value="no">否</Select.Option>
        </Select>
      </Form.Item>
    </Form>
  );
};

export default UserFilter; 